<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../../js/Width.js" type="text/javascript" charset="utf-8"></script>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/Setting.css" />
		
	</head>

	<body>
		<div id="password">
			<header class="mui-bar mui-bar-nav">
				<a style="color: #fff;" class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
				<h1 class="mui-title" style="color: #fff;">修改密码</h1>
			</header>
			<div class="content">

				<div class="input-wapper flex-between margin-top15 bottom-underline">
					<span>原密码：</span>
					<input  type="password" v-model="original" placeholder="请输入旧密码" maxlength="16" />
				</div>
				<div class="input-wapper flex-between bottom-underline">
					<span>新密码：</span>
					<input type="password" v-model="newPassword" placeholder="请输入新密码" maxlength="16" />
				</div>
				<div class="input-wapper flex-between bottom-underline">
					<span>确定密码：</span>
					<input type="password" v-model="verifyPassword" placeholder="请再次输入新密码" maxlength="16" />
				</div>
				<div class="submit-button" @click="submitClick">完成</div>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/util.js"></script>
		<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
		<script type="text/javascript">
			var Password = new Vue({
				el: '#password',
				data: {
					original: '',
					newPassword: '',
					verifyPassword: ''
				},
				methods: {
					submitClick: function() {
						if(!this.original || !this.newPassword  || !this.verifyPassword) {
							mui.toast('请输入完整')
							return
						}
						if(this.newPassword == this.verifyPassword) {
							   if(this.original == this.verifyPassword) {
							   	mui.toast('设置密码和原密码相同')
							   	return
							   }
								this.UpdatePwd(this.original,this.verifyPassword)
							}else{
								mui.toast('设置的密码不一致')
							}
					},
					UpdatePwd:function(original,verifyPassword){
						mui.post(httpUrl.testUrl+'/api/Users/UpdatePwd',{
							userID:plus.storage.getItem("userID"),
							 formerPwd:original,
							 userPwd:verifyPassword
						},function(res){
							if(res.code===1001){
								mui.toast('修改成功')
								plus.storage.removeItem("userID");
								setTimeout(function() {
									plus.runtime.restart();
								}, 500)
							}
						})
					}
				}
			})
			mui.init()
			mui.plusReady(function() {
				FastClick.attach( document.body );  
			})
		</script>
	</body>

</html>